<template>
	<view>
		<u-navbar :is-back="false" title="　" :border-bottom="false">
			<view class="u-flex u-row-right" style="width: 100%;">
				<!-- <view class="camera u-flex u-row-center">
					<u-icon name="camera-fill" color="#000000" size="48"></u-icon>
				</view> -->
			</view>
		</u-navbar>
		<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30">
			<view class="u-m-r-10">
				<u-avatar :src="userinfo.headpic" size="140"></u-avatar>
			</view>
			<view class="u-flex-1">
				<view class="u-font-18 u-p-b-20">{{userinfo.nickname}}</view>
				<view class="u-font-14 u-tips-color">余额:{{userinfo.money}}</view>
			</view>
			<!-- <view class="u-m-l-10 u-p-10">
				<u-icon name="scan" color="#969799" size="28"></u-icon>
			</view>
			<view class="u-m-l-10 u-p-10">
				<u-icon name="arrow-right" color="#969799" size="28"></u-icon>
			</view> -->
		</view>
		
		<view class="bangding" style="height: 50rpx;" v-if="!userinfo.mobile">
			<view>您还未绑定手机</view>
			<button class="bd-r" size="mini" open-type="getPhoneNumber" @getphonenumber="bind">绑定手机</button>

		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="rmb-circle" title="我的预约" @click="navUrl('/pages/my/myYuyue')"></u-cell-item>
			</u-cell-group>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				
				<u-cell-item icon="star" title="我的邀请" @click="navUrl('/pages/my/myInvite')"></u-cell-item>
					
				<u-cell-item icon="photo" title="提现" @click="navUrl('/pages/my/cash')"></u-cell-item>
				<u-cell-item icon="coupon" title="佣金记录" @click="navUrl('/pages/my/fx_recourd')"></u-cell-item>
				<u-cell-item icon="heart" title="收藏" @click="navUrl('/pages/my/collection')"></u-cell-item>
			</u-cell-group>
		</view>
		<XcxAuth :auth="auth" @userinfo="get_userinfo"></XcxAuth>
	</view>
</template>

<script>
	var _self;
	import XcxAuth from "@/components/wx_auth/xcx_auth.vue"
	import UserModel from '../../model/user.js'
	export default {
		components: {
			XcxAuth
		},
		data() {
			return {
				pic:'https://uviewui.com/common/logo.png',
				show:true,
				userinfo:{},
				auth: {
					is_name: false,
					is_address: false,
					is_phone: false,
				},
			}
		},
		onShow() {
				this.get_userinfo()
		},
		onLoad() {
			_self=this
		
		},
		methods: {
			get_userinfo() {
					UserModel.get_infor().then(res=>{
						
						uni.setStorageSync('infor',res.data)
						_self.userinfo=res.data
						_self.get_infor()
						
					})
			},
			bind(e){
				let obj = {}
				let that = this
				obj.iv = e.detail.iv
				obj.encryptedData = e.detail.encryptedData
				console.log(obj)
				UserModel.bind_mobile(obj).then(res=>{
					that.get_userinfo()
				})
			},
			get_infor(){
					 
					const my = uni.getStorageSync('infor');  
					
					if (my && my.headpic && my.nickname) {
						this.userinfo = my
						
					} else {
						//auth传到组件，组件监听auth是否有变动
						this.auth.is_name = !this.auth.is_name
					}
					
			},
			
		}
	}
</script>

<style lang="scss">
page{
	background-color: #ededed;
}

.camera{
	width: 54px;
	height: 44px;
	
	&:active{
		background-color: #ededed;
	}
}
.user-box{
	background-color: #fff;
}

.bangding {
			width: 100%;
			display: flex;
			justify-content: space-between;
			font-size: 12px;
			border-top: 1px solid #F1F3F6;
			padding: 10px 10px 0;

			.bd-l {
				height: 27px;
				line-height: 27px;
			}

			.bd-r {
				color: #FB526A;
				border: 1px solid #FB526A;
				border-radius: 3px;
				height: 24px;
				line-height: 24px;
				text-align: center;
				padding: 0 10px;
			}
		}
</style>
